package com.oreilly.ez.fileserver.base;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class SysConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {

//        LoginInterceptor loginInterceptor = new LoginInterceptor();
//        InterceptorRegistration loginRegistry = registry.addInterceptor(loginInterceptor);
//
//        // 拦截路径
//        loginRegistry.addPathPatterns("/**");
//        // 排除路径
//        loginRegistry.excludePathPatterns("/");
//        loginRegistry.excludePathPatterns("/login");
//        loginRegistry.excludePathPatterns("/loginout");
//        loginRegistry.excludePathPatterns("/swagger**/**/*.*");
//        loginRegistry.excludePathPatterns("/webjars/**/*.*");
////        loginRegistry.excludePathPatterns("/v2/api-docs");
////        loginRegistry.excludePathPatterns("/swagger-resources/configuration/ui");
////        loginRegistry.excludePathPatterns("/swagger-resources");
////        loginRegistry.excludePathPatterns("/swagger-resources/configuration/security");
////        loginRegistry.excludePathPatterns("/swagger-ui.html");
//
//
//        // 排除资源请求
//        loginRegistry.excludePathPatterns("/css/login/*.css");
//        loginRegistry.excludePathPatterns("/js/login/**/*.js");
//        loginRegistry.excludePathPatterns("/image/login/*.png");
//        loginRegistry.excludePathPatterns("/*.js");

    }


    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
    }
}
